<?php
/**
 * @filesource /modules/user/Form/Register.php
 * @abstract Generate a register form, where no lable is set
 *     see /modules/user/views/register/register.phtml for how the form is generated.
 */
class Form_Upload extends Zend_Form
{

    protected $_noDecorator = array(
        'ViewHelper', 
        'Errors'
    );

    public function cluBuild($params)
	//public function cluBuild($contentType, $contentId, $uid, $fileType, $view)
	{
//		die_a($params);
//		$actionForm = $view->hvnUrl(array('module' => 'file', 'action'=>'upload'), 'nocontroller') . '?c='.$contentType.'&id='.$contentId.'&t='.$fileType.'&uid='.$uid;
//		 	  ->setAction($actionForm)
		 $this->setName('upload_file')
		 	  ->setAttrib('enctype', 'multipart/form-data')
		 	  //->setAction('/en/file/index/upload?c='.$contentType.'&id='.$contentId.'&t='.$fileType.'&uid='.$uid)
		 	  ->setMethod('post');
		 	  
		$this->setAction($params['action_url']);
		//creating Form_Element_File
		$elementFile = new Zend_Form_Element_File('file_upload');
		
		if ($params['fileType'] === 'image')
		{
			$elementFile
					->addValidator('Count', false, 1)
					->addValidator('Size', false, 100*1024*1024*1000)
					->addValidator('IsImage', true)//, 'jpg,png,gif,txt,doc')
				  	->setRequired(true);
		}
		
		$this->addElement($elementFile);

		 // creating submit button
		$submit = new Zend_Form_Element_Submit('upload_button');
        $submit->setAttrib('id', 'upload_button')
        	   ->setLabel('Upload')
        	   ->addDecorators($this->_noDecorator);
        $this->addElement($submit);
    }
}

?>